/*************************************************************************
 * Copyright (C) 2008 Tavian Barnes <tavianator@gmail.com>               *
 *                                                                       *
 * This file is part of The FPFD Library Build Suite.                    *
 *                                                                       *
 * The FPFD Library Build Suite is free software; you can redistribute   *
 * it and/or modify it under the terms of the GNU General Public License *
 * as published by the Free Software Foundation; either version 3 of the *
 * License, or (at your option) any later version.                       *
 *                                                                       *
 * The FPFD Library Build Suite is distributed in the hope that it will  *
 * be useful, but WITHOUT ANY WARRANTY; without even the implied         *
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See *
 * the GNU General Public License for more details.                      *
 *                                                                       *
 * You should have received a copy of the GNU General Public License     *
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 *************************************************************************/

#include <stdio.h>

int main() {
  unsigned int lhs, rhs;
  unsigned int lhs_dec, rhs_dec;

  printf("/* Automatically generated by libfpfd-dpd/multable.c */\n"
         "\n"
         "        .section .rodata\n"
         ".globl fpfd_bcdmul\n"
         "        .align 32\n"
         "        .type fpfd_bcdmul, @object\n"
         "        .size fpfd_bcdmul, 78848\n"
         "fpfd_bcdmul:\n");

  lhs_dec = 0;
  rhs_dec = 0;
  for (lhs = 0; lhs <= 0x99; ++lhs) {
    for (rhs = 0; rhs < 0x100; ++rhs) {
      if ((lhs & 0xE) <= 0x8 && (lhs & 0xE0) <= 0x80
          && (rhs & 0xE) <= 0x8 && (rhs & 0xE0) <= 0x80) {
        printf("        .value 0x%u\n", lhs_dec*rhs_dec);
        ++rhs_dec;
      } else {
        printf("        .value 0x0\n");
      }
    }
    if ((lhs & 0xE) <= 0x8 && (lhs & 0xE0) <= 0x80) {
      ++lhs_dec;
      rhs_dec = 0;
    }
  }

  return 0;
}
